<%@ Page Title="Pay_QRCode List" Language="C#" AutoEventWireup="true" CodeBehind="Pay_QRCodeList.aspx.cs" Inherits="Youz.CreditRepay.Manage.Pay_QRCodeList" %>

<script>
    //loadCSS("assets/plugins/gritter/css/jquery.gritter.css");

    var requireJS = [
        //"assets/plugins/gritter/js/jquery.gritter.min.js"
    ];

    loadJS(requireJS);
</script>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading" data-original-title>
                <h2><i class="fa fa-align-justify"></i><span class="break"></span><%: R(LanguageModule.Pay_QRCode, "Pay_QRCode", "支付二维码") %></h2>
                <div class="panel-actions"></div>
            </div>
            <div class="panel-body">
                <div class="alert alert-danger" style="display: none;">
                    <button type="button" class="close" data-dismiss="alert">×</button><strong><i class="fa fa-warning"></i></strong><span class="content"></span>
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <div class="input-group">
                            <input type="email" id="input2-group2" name="input2-group2" class="form-control" placeholder="Search..."><span class="input-group-btn">
                                <button type="button" class="btn btn-primary">
                                    <i class="fa fa-search "></i>
                                    <%: R(LanguageModule.M_Common, "Query") %></button></span>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <a href="#" class="btn btn-info" onclick="loadPage('Pay/Pay_QRCodeItem.aspx?t=<%: WebHelper.Get<int>("t")%>')"><i class="fa fa-plus"></i>
                            <%: R(LanguageModule.M_Common, "Add") %></a>
                        <a href="#" class="btn btn-info" id="btnEdit"><i class="fa fa-edit "></i>
                            <%: R(LanguageModule.M_Common, "Edit") %></a>
                        <a href="#" class="btn btn-info" id="btnDelete"><i class="fa fa-trash-o "></i>
                            <%: R(LanguageModule.M_Common, "Delete") %></a>
                    </div>
                </div>
                <table id="table" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%"></table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var dt;

    $(function () {

        dt = $('#table').DataTable({
            "ajax": {
                "url": 'Pay/Handlers/Pay_QRCodeHandler.ashx?type=list',
                "type": "POST",
                "dataSrc": "data",
                "data": function (d) {
                    d.PayType = <%: WebHelper.Get<int>("t") %>;
                }
            },
            "columns": [

                    { "data": 'ID', "title": "<%: R(LanguageModule.Pay_QRCode, "ID", "ID") %>", visible: false },
                    { "data": 'Amount', "title": "<%: R(LanguageModule.Pay_QRCode, "Amount", "面值") %>" },
                    { "data": 'Name', "title": "<%: R(LanguageModule.Pay_QRCode, "Name", "名称") %>" },
                    { "data": 'Img', "title": "<%: R(LanguageModule.Pay_QRCode, "Img", "QR码图片") %>" },
                    { "data": 'Remark', "title": "<%: R(LanguageModule.Pay_QRCode, "Remark", "说明") %>" },
                    { "data": 'CreateTime', "title": "<%: R(LanguageModule.Pay_QRCode, "CreateTime", "新建时间") %>" },
                    { "data": 'ModifyTime', "title": "<%: R(LanguageModule.Pay_QRCode, "ModifyTime", "更新时间") %>" },
            ]
        });

        //delete selected row
        $('#btnDelete').click(function () {
            if ($('#table tbody tr.selected').length > 0) {
                jconfirm("<%: R(LanguageModule.M_Common, "DeleteConfirm") %>", function () {
                      //console.log(dt.row('.selected').data());
                      $.post("Pay/Handlers/Pay_QRCodeHandler.ashx?type=delete<%: WebHelper.Get("st") %>", { ID: dt.row('.selected').data().ID }, function (data) {
                          if (data) {
                              if (data.isSuccess) {
                                  dt.ajax.reload();

                                  $.gritter.add({
                                      title: '<%: R(LanguageModule.M_Common, "TipSuccess") %>',
                                    text: data.message,
                                    class_name: 'gritter-success'
                                });

                                $('#table tbody tr.selected').remove();
                            }
                        }
                    }, "json");
                  });
            }
            else {
                $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
                  $(".alert").show();
              }
          });

        //delete selected row
        $('#btnEdit').click(function () {
            if ($('#table tbody tr.selected').length > 0) {
                loadPage("Pay/Pay_QRCodeItem.aspx?t=<%: WebHelper.Get<int>("t")%>&ID=" + dt.row('.selected').data().ID);
            }
            else {
                $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
                  $(".alert").show();
              }
          });

    });
</script>
